// 某个数值在一个数组中较为接近的一个值的下标,返回这个下标
export default function(arr, val) {
  let idx = 0;
  let diff = Infinity;
  arr.forEach((el, i) => {
    if (Math.abs(el - val) < diff) {
      idx = i;
      diff = Math.abs(el - val);
    }
  });
  return idx;
}
